﻿Public Class LogCommon
    'ログ書込みの関数
    Public Function writeLog(ByVal actionName As String, ByVal logContent As String) As Boolean

        Dim ret = True
        Dim sr As System.IO.StreamWriter
        Try
            If IO.Directory.Exists(My.Settings.LogPath) = False Then
                MessageCommon.showError(My.Resources.E_LOGPATH_NOT_EXISTED)
            End If
            Dim enc As System.Text.Encoding = System.Text.Encoding.GetEncoding("Shift_JIS")
            Dim fileName As String = DateTime.Today.Year & "." & DateTime.Today.Month & "." & DateTime.Today.Day & ".txt"
            sr = New System.IO.StreamWriter(My.Settings.LogPath & "\" & fileName, True, enc)
            sr.WriteLine("::")
            sr.WriteLine("＠時刻：" & DateTime.Now)
            sr.WriteLine("＠アクション：" & actionName)
            sr.WriteLine("＠利用者：" & My.Settings.CurrentUserID)
            sr.WriteLine("＠詳細情報：")
            sr.WriteLine(logContent)
            sr.Close()
        Catch ex As Exception
            ret = False
        End Try
        Return ret
    End Function
    'ログ書込みの関数
    Public Shared Function writeDebug(ByVal logContent As String) As Boolean
        Dim ret = True
        Dim sr As System.IO.StreamWriter
        Try
            Dim enc As System.Text.Encoding = System.Text.Encoding.GetEncoding("Shift_JIS")
            sr = New System.IO.StreamWriter(My.Settings.LogPath & "debug.txt", True, enc)
            sr.WriteLine("::")
            sr.WriteLine("＠時刻：" & DateTime.Now)
            sr.WriteLine("＠詳細：")
            sr.WriteLine(logContent)
            sr.Close()
        Catch ex As Exception
            ret = False
        End Try
        Return ret
    End Function
End Class